package com.geping.etl.common.service.impl;

import com.geping.etl.common.entity.CmdTaskConfig;
import com.geping.etl.common.repository.CmdTaskConfigRepository;
import com.geping.etl.common.service.CmdTaskConfigService;
import com.microsoft.schemas.office.office.STInsetMode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CmdTaskConfigServiceImpl implements CmdTaskConfigService {

    @Autowired
    private CmdTaskConfigRepository cmdTaskConfigRepository;

    @Override
    public CmdTaskConfig getPath() {
        return cmdTaskConfigRepository.getPath();
    }

    // 新增
    @Override
    public CmdTaskConfig save(CmdTaskConfig cmdTaskConfig) {
        return cmdTaskConfigRepository.save(cmdTaskConfig);
    }

   /* @Transactional
    @Override
    public CmdTaskConfig save(TaskConfigAddOrUpdateDto taskConfigAddOrUpdateDto) {
        CmdTaskConfig cmdTaskConfig=new CmdTaskConfig();
        cmdTaskConfig.setId(taskConfigAddOrUpdateDto.getId());
        cmdTaskConfig.setName(taskConfigAddOrUpdateDto.getPathname());
        cmdTaskConfig.setSubject(taskConfigAddOrUpdateDto.getSubject());
        cmdTaskConfig.setTask(taskConfigAddOrUpdateDto.getTask());
        return cmdTaskConfigRepository.save(cmdTaskConfig);
    }*/


    @Override
    public Page<CmdTaskConfig> findAll(Specification<CmdTaskConfig> spec, Pageable pageable) {
        return cmdTaskConfigRepository.findAll(spec, pageable);
    }

    @Override
    public Integer update(String name, String task, String odspath,String data_data,Integer id) {
        return cmdTaskConfigRepository.update(name,task,odspath,data_data,id);
    }

    @Override
    public Integer deleteByIds(List<Integer>  ids) {
        return cmdTaskConfigRepository.deleteByIds(ids);
    }

/*
    @Override
    public int deleteByIds(String ids) {
        StringBuffer sql = new StringBuffer();
        if (StringUtils.isNotBlank(ids)) {
           ids = ids.substring(0, ids.length()-1);
            sql.append("DELETE FROM PERSONAPATH where id in("+ids+")");
        }else {
            sql.append("DELETE FROM PERSONAPATH where 1=1");
        }
        return cmdTaskConfigRepository.deleteByIds(ids);
    }*/

}